package com.css.fxfzysx.modules.lifeline.repository.impl;

import com.alibaba.fastjson.JSONObject;
import com.css.fxfzysx.base.dict.service.DictService;
import com.css.fxfzysx.modules.cztDataMange.entity.RdInformationEntity;
import com.css.fxfzysx.modules.lifeline.entity.newEntity.*;
import com.css.fxfzysx.modules.lifeline.param.PageParam;
import com.css.fxfzysx.modules.lifeline.param.RegionParam;
import com.css.fxfzysx.modules.lifeline.repository.LifelineEngineeringRepository;
import com.css.fxfzysx.modules.lifeline.vo.LifelineIdVo;
import com.css.fxfzysx.modules.lifeline.vo.fxqh.DataSourceVo;
import com.css.fxfzysx.modules.lifeline.vo.fxqh.EvaluationResults;
import com.css.fxfzysx.modules.vaomeFacilities.entity.CztMajorProjectsEntity;
import com.css.fxfzysx.util.PlatformDateUtils;
import com.css.fxfzysx.util.PlatformObjectUtils;
import com.css.fxfzysx.util.PlatformSessionUtils;
import com.css.fxfzysx.web.PlatformSessionContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
@Slf4j
public class LifelineEngineeringRepositoryImpl implements LifelineEngineeringRepository {

    @Resource
    private JdbcTemplate jdbcTemplate;

    @Resource
    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    @Autowired
    private DictService dictService;

    @Override
    public List<SmxVersionEntity> getByRegionAndUserAndType(RegionParam param, String fileName) {
        try {
            String userId = param.getUserId();
            Integer type = param.getType();
            String province = param.getProvince();
            String city = param.getCity();
            String county = param.getCounty();
            String sql = "select * from czt_smx_version where province = '" + province + "' and city = '" + city + "' and county = '" + county + "' and create_user = '" + userId + "' and type = " + type + " and file_name = '" + fileName + "' and del_flag = '0'";
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(SmxVersionEntity.class));
        } catch (DataAccessException e) {
            return null;
        }
    }

    @Override
    public void deleteOldVersionData(String versionId, Integer type, Integer bridgeType) {
        StringBuilder sql = new StringBuilder("update ");
        switch (type) {
            case 1:
                sql.append(" czt_smx_up_network");
                break;
            case 2:
                sql.append(" czt_smx_water_supply");
                break;
            case 3:
                sql.append(" czt_smx_air_receiver");
                break;
            case 4:
                if (bridgeType == 0) {
                    sql.append(" czt_smx_bridge_point");
                } else {
                    sql.append(" czt_smx_bridge_line");
                }
                break;
            case 5:
                sql.append(" czt_smx_road");
                break;
            case 6:
                sql.append(" czt_smx_transformer_substation");
                break;
            case 7:
                sql.append(" czt_smx_overhead_line");
                break;
            case 8:
                sql.append(" czt_smx_cable_route");
                break;
            case 9:
                sql.append(" czt_smx_devices");
                break;
            case 10:
                sql.append(" czt_smx_tv_tower");
                break;
            case 11:
                sql.append(" czt_smx_water_room");
                break;
            case 12:
                sql.append(" czt_smx_powerhouse");
                break;
            case 14:
                sql.append(" czt_smx_gas_store");
                break;
            case 13:
                sql.append(" czt_smx_base_station");
                break;
            case 16:
                sql.append(" czt_major_projects");
                break;
            case 17:
                sql.append(" czt_reservior");
        }
        StringBuilder sb = new StringBuilder(" set del_flag = '1' where version_id = '" + versionId + "'");
        jdbcTemplate.update(sql.append(sb).toString());
    }

    @Override
    public Map<String, Object> getVersionCode(RegionParam param) {
        Integer type = param.getType();
        Integer page = param.getPage();
        Integer size = param.getRows();

        StringBuilder sql = new StringBuilder("select * from czt_smx_version where del_flag = '0' and type = " + type);
        if (PlatformObjectUtils.isNotEmpty(param.getProvince())) {
            sql.append(" and province = '" + param.getProvince() + "'");
        }
        if (PlatformObjectUtils.isNotEmpty(param.getCity())) {
            sql.append(" and city = '" + param.getCity() + "'");
        }
        if (PlatformObjectUtils.isNotEmpty(param.getCounty())) {
            sql.append(" and county = '" + param.getCounty() + "'");
        }
        StringBuilder orderSql = new StringBuilder(" order by create_time desc");
        Integer total = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxVersionEntity.class)).size();
        StringBuilder limitSql = new StringBuilder(" limit " + size + " offset " + (page - 1) * size);
        sql.append(orderSql).append(limitSql);
        List<SmxVersionEntity> data = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxVersionEntity.class));
        HashMap<String, Object> resultMap = new HashMap<>();
        resultMap.put("total", total);
        resultMap.put("rows", data);
        return resultMap;
    }

    @Override
    public SmxVersionEntity getById(String versionId) {
        try {
            String sql = "select * from czt_smx_version where id = '" + versionId + "'";
            return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(SmxVersionEntity.class));
        } catch (DataAccessException e) {
            return null;
        }
    }

    @Override
    public void saveSmxVersion(SmxVersionEntity entity) {
        jdbcTemplate.update("insert into czt_smx_version  (id,version_code,province,city,county,file_name,file_ids,create_user,create_user_name,create_time,del_flag,type,version_status,bridge_type) values (?,?,?,?,?,?,?,?,?,?,?,?,?,? )",
                entity.getId(), entity.getVersionCode(), entity.getProvince(), entity.getCity(), entity.getCounty(), entity.getFileName(), entity.getFileIds(), entity.getCreateUser(), entity.getCreateUserName(), entity.getCreateTime(), entity.getDelFlag(), entity.getType(), entity.getVersionStatus(), entity.getBridgeType());
    }


    @Override
    public void updateSmxVersion(SmxVersionEntity entity) {
        jdbcTemplate.update("update czt_smx_version set file_ids=?,update_user=?,update_time=?,version_status=? where id = ?", entity.getFileIds(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getVersionStatus(), entity.getId());
    }

    @Override
    public Map<String, Object> getLifelineDataSource(PageParam param) {
        HashMap<String, Object> map = new HashMap<>();
        Integer type = param.getType();
        if (type == 15) {
            type = 1;
        }
        StringBuilder sql = new StringBuilder("select * from czt_smx_version where type = '" + type + "' and del_flag = '0' ");
        if (PlatformObjectUtils.isNotEmpty(param.getProvince())) {
            sql.append(" and province = '" + param.getProvince() + "'");
        }
        if (PlatformObjectUtils.isNotEmpty(param.getCity())) {
            sql.append(" and city = '" + param.getCity() + "'");
        }
        if (PlatformObjectUtils.isNotEmpty(param.getCounty())) {
            sql.append(" and county = '" + param.getCounty() + "'");
        }
        if (PlatformObjectUtils.isNotEmpty(param.getVersionCode())) {
            sql.append(" and version_code like '%" + param.getVersionCode() + "%'");
        }
        if (PlatformObjectUtils.isNotEmpty(param.getCreateUserName())) {
            sql.append(" and create_user_name like '%" + param.getCreateUserName() + "%'");
        }

        int size = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(Object.class)).size();
        map.put("total", size);

        StringBuilder limitSql = new StringBuilder(" limit " + param.getRows() + " offset " + (param.getPage() - 1) * param.getRows());
        StringBuilder orderSql = new StringBuilder(" order by create_time desc");
        sql.append(orderSql).append(limitSql);
        List<DataSourceVo> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(DataSourceVo.class));
        map.put("rows", list);
        return map;
    }

    @Override
    public Map<String, Object> getByTypeAndVersionId(int page, int size, String versionId, Integer type) {
        HashMap<String, Object> map = new HashMap<>();
        StringBuilder sql = new StringBuilder("select * from ");
        if (type == 1) {
            sql.append(" czt_smx_up_network");
        } else if (type == 2) {
            sql.append(" czt_smx_water_supply");
        } else if (type == 3) {
            sql.append(" czt_smx_air_receiver");
        } else if (type == 4) {
            sql.append(" czt_smx_bridge_line");
        } else if (type == 5) {
            sql.append(" czt_smx_road");
        } else if (type == 6) {
            sql.append(" czt_smx_transformer_substation");
        } else if (type == 7) {
            sql.append(" czt_smx_overhead_line");
        } else if (type == 8) {
            sql.append(" czt_smx_cable_route");
        } else if (type == 9) {
            sql.append(" czt_smx_devices");
        } else if (type == 10) {
            sql.append(" czt_smx_tv_tower");
        } else if (type == 11) {
            sql.append(" czt_smx_water_room");
        } else if (type == 12) {
            sql.append(" czt_smx_powerhouse");
        } else if (type == 13) {
            sql.append(" czt_smx_base_station");
        } else if (type == 14) {
            sql.append(" czt_smx_gas_store");
        } else if (type == 16) {
            sql.append(" czt_major_projects");
        } else if (type == 17) {
            sql.append(" czt_reservior");
        }
        sql.append(" where del_flag = '0' and version_id = '" + versionId + "'");

        if (type == 4) {
            sql.append(" union all select * from czt_smx_bridge_point where del_flag = '0' and version_id = '" + versionId + "'");
        }

        StringBuilder orderSql = new StringBuilder(" order by serial_number asc ");
        StringBuilder limitSql = new StringBuilder(" limit " + size + " offset " + (page - 1) * size);

        Integer total = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(Object.class)).size();

        if (type == 1) {
            List<SmxUpNetworkEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxUpNetworkEntity.class));
            map.put("rows", list);
        } else if (type == 2) {
            List<SmxWaterSupplyEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxWaterSupplyEntity.class));
            map.put("rows", list);
        } else if (type == 3) {
            List<SmxAirReceiverEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxAirReceiverEntity.class));
            map.put("rows", list);
        } else if (type == 4) {
            List<SmxBridgeEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxBridgeEntity.class));
            map.put("rows", list);
        } else if (type == 5) {
            List<SmxRoadEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxRoadEntity.class));
            map.put("rows", list);
        } else if (type == 6) {
            List<SmxTransformerSubstationEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxTransformerSubstationEntity.class));
            map.put("rows", list);
        } else if (type == 7) {
            List<SmxOverheadLineEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxOverheadLineEntity.class));
            map.put("rows", list);
        } else if (type == 8) {
            List<SmxCableRouteEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxCableRouteEntity.class));
            map.put("rows", list);
        } else if (type == 9) {
            List<SmxDevicesEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxDevicesEntity.class));
            map.put("rows", list);
        } else if (type == 10) {
            List<SmxTvTowerEntity> list = jdbcTemplate.query(sql.append(orderSql).append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxTvTowerEntity.class));
            map.put("rows", list);
        } else if (type == 11) {
            List<SmxWaterRoomEntity> list = jdbcTemplate.query(sql.append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxWaterRoomEntity.class));
            map.put("rows", list);
        } else if (type == 12) {
            List<SmxPowerhouseEntity> list = jdbcTemplate.query(sql.append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxPowerhouseEntity.class));
            map.put("rows", list);
        } else if (type == 13) {
            List<SmxBaseStationEntity> list = jdbcTemplate.query(sql.append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxBaseStationEntity.class));
            map.put("rows", list);
        } else if (type == 14) {
            List<SmxGasStoreEntity> list = jdbcTemplate.query(sql.append(limitSql).toString(), new BeanPropertyRowMapper<>(SmxGasStoreEntity.class));
            map.put("rows", list);
        } else if (type == 16) {
            List<CztMajorProjectsEntity> list = jdbcTemplate.query(sql.append(limitSql).toString(), new BeanPropertyRowMapper<>(CztMajorProjectsEntity.class));
            map.put("rows", list);
        } else if (type == 17) {
            List<RdInformationEntity> list = jdbcTemplate.query(sql.append(limitSql).toString(), new BeanPropertyRowMapper<>(RdInformationEntity.class));
            map.put("rows", list);
        }
        map.put("total", total);
        return map;
    }

    @Override
    public void deleteByTypeAndId(String id, Integer type) {
        String fieldName = "id";
        StringBuilder sql = new StringBuilder("update ");
        if (type == 1) {
            sql.append(" czt_smx_up_network");
        } else if (type == 2) {
            sql.append(" czt_smx_water_supply");
        } else if (type == 3) {
            sql.append(" czt_smx_air_receiver");
        } else if (type == 4) {
            sql.append(" czt_smx_bridge_point");
        } else if (type == 5) {
            sql.append(" czt_smx_road");
        } else if (type == 6) {
            sql.append(" czt_smx_transformer_substation");
        } else if (type == 7) {
            fieldName = "col_id";
            sql.append(" czt_smx_overhead_line");
        } else if (type == 8) {
            fieldName = "ccr_id";
            sql.append(" czt_smx_cable_route");
        } else if (type == 9) {
            sql.append(" czt_smx_devices");
        } else if (type == 10) {
            fieldName = "ctt_id";
            sql.append(" czt_smx_tv_tower");
        } else if (type == 11) {
            sql.append(" czt_smx_water_room");
        } else if (type == 12) {
            sql.append(" czt_smx_powerhouse");
        } else if (type == 13) {
            sql.append(" czt_smx_base_station");
        } else if (type == 14) {
            sql.append(" czt_smx_gas_store");
        } else if (type == 16) {
            sql.append(" czt_major_projects");
        } else if (type == 17) {
            fieldName = "cr_id";
            sql.append(" czt_reservior");
        }
        sql.append(" set del_flag = '1' where "+fieldName+" in (" + id + ")");
        jdbcTemplate.update(sql.toString());
    }

    @Override
    public void updateById(Integer k, Object v, String userId) {
        if (k == 1) {
            SmxUpNetworkEntity entity = JSONObject.parseObject(JSONObject.toJSONString(v), SmxUpNetworkEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_up_network  SET up_id=?,type=?,start_id=?,end_id=?,longitude=?,latitude=?,length=?,site_classification=?,material=?,diameter=?,intensity=?,year=?,joint=?,disaster_rate6=?,disaster_rate7=?,disaster_rate8=?,disaster_rate9=?,disaster_rate10=?,material_type=?,elasticity_modulus=?,yield_limit_stress=?,strength_limit_stress=?,permissible_strain=?,thickness=?,pressure=?,jointy=?,allowable_elongation=?,liquefaction6=?,liquefaction7=?,liquefaction8=?,liquefaction9=?,seismic_subsidence6=?,seismic_subsidence7=?,seismic_subsidence8=?,seismic_subsidence9=?,depth=?,max_speed=?,max_accelaration=?,longitudinal_wave_velocity=?,transverse_wave_velocity=?,max_pipeline_strain=?,cross_sectional_area=?,earthquake_wavelength=?,earthquakewave_incident_angle=?,poissons_ratio=?,soilbulk_density1=?,burial_depth=?,soilstatic_pressure_coefficient=?,pipe_od=?,inside_diameter=?,t_buried_depth=?,linear_expansion_coefficient=?,correction_factor=?,temperature_difference=?,internal_pressure=?,curvature=?,soil_lateral_pressure=?,soilbulk_density2=?,soil_burial_depth=?,adjustment_coefficient1=?,adjustment_coefficient2=?,ground_motion_speed=?,surface_wave_velocity=?,interface_reduction_coefficient=?,single_pipe_length=?,soil_pressure=?,internal_water_pressure=?,foundation_z_coefficient=?,note=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where id=?",
                    entity.getUpId(), entity.getType(), entity.getStartId(), entity.getEndId(), entity.getLongitude(), entity.getLatitude(), entity.getLength(), entity.getSiteClassification(), entity.getMaterial(), entity.getDiameter(), entity.getIntensity(), entity.getYear(), entity.getJoint(), entity.getDisasterRate6(), entity.getDisasterRate7(), entity.getDisasterRate8(), entity.getDisasterRate9(), entity.getDisasterRate10(), entity.getMaterialType(), entity.getElasticityModulus(), entity.getYieldLimitStress(), entity.getStrengthLimitStress(), entity.getPermissibleStrain(), entity.getThickness(), entity.getPressure(), entity.getJointy(), entity.getAllowableElongation(), entity.getLiquefaction6(), entity.getLiquefaction7(), entity.getLiquefaction8(), entity.getLiquefaction9(), entity.getSeismicSubsidence6(), entity.getSeismicSubsidence7(), entity.getSeismicSubsidence8(), entity.getSeismicSubsidence9(), entity.getDepth(), entity.getMaxSpeed(), entity.getMaxAccelaration(), entity.getLongitudinalWaveVelocity(), entity.getTransverseWaveVelocity(), entity.getMaxPipelineStrain(), entity.getCrossSectionalArea(), entity.getEarthquakeWavelength(), entity.getEarthquakewaveIncidentAngle(), entity.getPoissonsRatio(), entity.getSoilbulkDensity1(), entity.getBurialDepth(), entity.getSoilstaticPressureCoefficient(), entity.getPipeOd(), entity.getInsideDiameter(), entity.getTBuriedDepth(), entity.getLinearExpansionCoefficient(), entity.getCorrectionFactor(), entity.getTemperatureDifference(), entity.getInternalPressure(), entity.getCurvature(), entity.getSoilLateralPressure(), entity.getSoilbulkDensity2(), entity.getSoilBurialDepth(), entity.getAdjustmentCoefficient1(), entity.getAdjustmentCoefficient2(), entity.getGroundMotionSpeed(), entity.getSurfaceWaveVelocity(), entity.getInterfaceReductionCoefficient(), entity.getSinglePipeLength(), entity.getSoilPressure(), entity.getInternalWaterPressure(), entity.getFoundationZCoefficient(), entity.getNote(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getId()
            );
        } else if (k == 2) {
            SmxWaterSupplyEntity entity = JSONObject.parseObject(JSONObject.toJSONString(v), SmxWaterSupplyEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("update  czt_smx_water_supply  set water_supply_id=?,style=?,material=?,thickness=?,shape=?,radius=?,slength=?,length=?,capacity=?,depth=?,height=?,intensity=?,year=?,rebar_type=?,section_width=?,section_height=?,section_bending_moment=?,steel_strain=?,diameter_of_tensile_reinforcement=?,reinforcement_ratio=?,shape_factor1=?,shape_factor2=?,average_strain=?,elastic_modulus=?,distance=?,joint=?,present=?,quality=?,surface_shape1=?,surface_shape2=?,diameter1=?,diameter2=?,strength_grade=?,rupture_strength=?,kinds1=?,kinds2=?,thickness_of_protective_layer1=?,thickness_of_protective_layer2=?,vertical_reinforcement1=?,vertical_reinforcement2=?,site=?,liquefaction6=?,liquefaction7=?,liquefaction8=?,liquefaction9=?,landform6=?,landform7=?,landform8=?,landform9=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where id=?",
                    entity.getWaterSupplyId(), entity.getStyle(), entity.getMaterial(), entity.getThickness(), entity.getShape(), entity.getRadius(), entity.getSlength(), entity.getLength(), entity.getCapacity(), entity.getDepth(), entity.getHeight(), entity.getIntensity(), entity.getYear(), entity.getRebarType(), entity.getSectionWidth(), entity.getSectionHeight(), entity.getSectionBendingMoment(), entity.getSteelStrain(), entity.getDiameterOfTensileReinforcement(), entity.getReinforcementRatio(), entity.getShapeFactor1(), entity.getShapeFactor2(), entity.getAverageStrain(), entity.getElasticModulus(), entity.getDistance(), entity.getJoint(), entity.getPresent(), entity.getQuality(), entity.getSurfaceShape1(), entity.getSurfaceShape2(), entity.getDiameter1(), entity.getDiameter2(), entity.getStrengthGrade(), entity.getRuptureStrength(), entity.getKinds1(), entity.getKinds2(), entity.getThicknessOfProtectiveLayer1(), entity.getThicknessOfProtectiveLayer2(), entity.getVerticalReinforcement1(), entity.getVerticalReinforcement2(), entity.getSite(), entity.getLiquefaction6(), entity.getLiquefaction7(), entity.getLiquefaction8(), entity.getLiquefaction9(), entity.getLandform6(), entity.getLandform7(), entity.getLandform8(), entity.getLandform9(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getId()
            );
        } else if (k == 3) {
            SmxAirReceiverEntity entity = JSONObject.parseObject(JSONObject.toJSONString(v), SmxAirReceiverEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_air_receiver  SET air_receiver_id=?,name=?,longitude=?,latitude=?,year=?,style=?,capacity=?,pressure=?,inner_diameter=?,height=?,thickness=?,weight=?,material=?,structural_style=?,rail_length=?,rail_height=?,thickness1=?,base_type=?,site=?,fortification=?,material_type=?,elasticity_modulus=?,yield_stress=?,permissible_stress=?,liquefaction6=?,liquefaction7=?,liquefaction8=?,liquefaction9=?,seismic_subsidence6=?,seismic_subsidence7=?,seismic_subsidence8=?,seismic_subsidence9=?,intensity=?,weld_width=?,weld_height=?,weld_stress=?,damaged_weld_length=?,axis_radius=?,yield_stress1=?,ultimate_capacity=?,calculated_length=?,bottom_plate_length=?,welding_width=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where id=?",
                    entity.getAirReceiverId(), entity.getName(), entity.getLongitude(), entity.getLatitude(), entity.getYear(), entity.getStyle(), entity.getCapacity(), entity.getPressure(), entity.getInnerDiameter(), entity.getHeight(), entity.getThickness(), entity.getWeight(), entity.getMaterial(), entity.getStructuralStyle(), entity.getRailLength(), entity.getRailHeight(), entity.getThickness1(), entity.getBaseType(), entity.getSite(), entity.getFortification(), entity.getMaterialType(), entity.getElasticityModulus(), entity.getYieldStress(), entity.getPermissibleStress(), entity.getLiquefaction6(), entity.getLiquefaction7(), entity.getLiquefaction8(), entity.getLiquefaction9(), entity.getSeismicSubsidence6(), entity.getSeismicSubsidence7(), entity.getSeismicSubsidence8(), entity.getSeismicSubsidence9(), entity.getIntensity(), entity.getWeldWidth(), entity.getWeldHeight(), entity.getWeldStress(), entity.getDamagedWeldLength(), entity.getAxisRadius(), entity.getYieldStress1(), entity.getUltimateCapacity(), entity.getCalculatedLength(), entity.getBottomPlateLength(), entity.getWeldingWidth(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getId()
            );
        } else if (k == 4) {
            SmxBridgeEntity entity = JSONObject.parseObject(JSONObject.toJSONString(v), SmxBridgeEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_bridge_point SET bridge_id=?,longitude=?,latitude=?,across_object=?,intensity=?,year=?,fortification=?,structure=?,max_span=?,length=?,site_soil=?,grade=?,foundation_fail=?,super_structure=?,bearing=?,pier_height=?,pier_material=?,basement=?,number=?,capacity=?,abutment_mat=?,abutment_type=?,expansion_joint=?,width=?,note=?,name=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where id=?",
                    entity.getBridgeId(), entity.getLongitude(), entity.getLatitude(), entity.getAcrossObject(), entity.getIntensity(), entity.getYear(), entity.getFortification(), entity.getStructure(), entity.getMaxSpan(), entity.getLength(), entity.getSiteSoil(), entity.getGrade(), entity.getFoundationFail(), entity.getSuperStructure(), entity.getBearing(), entity.getPierHeight(), entity.getPierMaterial(), entity.getBasement(), entity.getNumber(), entity.getCapacity(), entity.getAbutmentMat(), entity.getAbutmentType(), entity.getExpansionJoint(), entity.getWidth(), entity.getNote(), entity.getName(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getId()
            );
        } else if (k == 5) {
            SmxRoadEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxRoadEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_road  SET road_id=?,name=?,grade=?,intensity=?,roadbed_soil=?,site_soil=?,fortification=?,foundation_fail=?,roadbed_type=?,roadbed_high=?,year=?,capacity=?,pavement=?,length=?,width=?,note=?,start_longitude=?,start_latitude=?,end_longitude=?,end_latitude=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where id=?",
                    entity.getRoadId(), entity.getName(), entity.getGrade(), entity.getIntensity(), entity.getRoadbedSoil(), entity.getSiteSoil(), entity.getFortification(), entity.getFoundationFail(), entity.getRoadbedType(), entity.getRoadbedHigh(), entity.getYear(), entity.getCapacity(), entity.getPavement(), entity.getLength(), entity.getWidth(), entity.getNote(), entity.getStartLongitude(), entity.getStartLatitude(), entity.getEndLongitude(), entity.getEndLatitude(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getId()
            );
        } else if (k == 6) {
            SmxTransformerSubstationEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxTransformerSubstationEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_transformer_substation  SET province=?,city=?,county=?,ts_id=?,name=?,position=?,longitude=?,latitude=?,type_of_ubstation=?,voltage_grade=?,structure_type=?,fortification_intensity=?,year=?,samples_number=?,pga=?,damages_number=?,substation_total_cost=?,equipment_outdoors=?,cost_of_indoor_equipment=?,cost_of_building=?,site=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where id=?",
                    entity.getProvince(), entity.getCity(), entity.getCounty(), entity.getTsId(), entity.getName(), entity.getPosition(), entity.getLongitude(), entity.getLatitude(), entity.getTypeOfUbstation(), entity.getVoltageGrade(), entity.getStructureType(), entity.getFortificationIntensity(), entity.getYear(), entity.getSamplesNumber(), entity.getPga(), entity.getDamagesNumber(), entity.getSubstationTotalCost(), entity.getEquipmentOutdoors(), entity.getCostOfIndoorEquipment(), entity.getCostOfBuilding(), entity.getSite(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getId()
            );
        } else if (k == 7) {
            SmxOverheadLineEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxOverheadLineEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_overhead_line  SET id=?,col_name=?,fortification_intensity=?,voltage_grade35=?,line_length35=?,loop_length35=?,landform35=?,unit_cost_line35=?,type35=?,number35=?,unit_cost_tower35=?,voltage_grade66=?,line_length66=?,loop_length66=?,landform66=?,unit_cost_line66=?,type66=?,number66=?,unit_cost_tower66=?,voltage_grade110=?,line_length110=?,loop_length110=?,landform110=?,unit_cost_line110=?,type110=?,number110=?,unit_cost_tower110=?,voltage_grade220=?,line_length220=?,loop_length220=?,landform220=?,unit_cost_line220=?,type220=?,number220=?,unit_cost_tower220=?,voltage_grade330=?,line_length330=?,loop_length330=?,landform330=?,unit_cost_line330=?,type330=?,number330=?,unit_cost_tower330=?,voltage_grade500=?,line_length500=?,loop_length500=?,landform500=?,unit_cost_line500=?,type500=?,number500=?,unit_cost_tower500=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where col_id=?",
                    entity.getId(), entity.getColName(), entity.getFortificationIntensity(), entity.getVoltageGrade35(), entity.getLineLength35(), entity.getLoopLength35(), entity.getLandform35(), entity.getUnitCostLine35(), entity.getType35(), entity.getNumber35(), entity.getUnitCostTower35(), entity.getVoltageGrade66(), entity.getLineLength66(), entity.getLoopLength66(), entity.getLandform66(), entity.getUnitCostLine66(), entity.getType66(), entity.getNumber66(), entity.getUnitCostTower66(), entity.getVoltageGrade110(), entity.getLineLength110(), entity.getLoopLength110(), entity.getLandform110(), entity.getUnitCostLine110(), entity.getType110(), entity.getNumber110(), entity.getUnitCostTower110(), entity.getVoltageGrade220(), entity.getLineLength220(), entity.getLoopLength220(), entity.getLandform220(), entity.getUnitCostLine220(), entity.getType220(), entity.getNumber220(), entity.getUnitCostTower220(), entity.getVoltageGrade330(), entity.getLineLength330(), entity.getLoopLength330(), entity.getLandform330(), entity.getUnitCostLine330(), entity.getType330(), entity.getNumber330(), entity.getUnitCostTower330(), entity.getVoltageGrade500(), entity.getLineLength500(), entity.getLoopLength500(), entity.getLandform500(), entity.getUnitCostLine500(), entity.getType500(), entity.getNumber500(), entity.getUnitCostTower500(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getColId()
            );
        } else if (k == 8) {
            SmxCableRouteEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxCableRouteEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_cable_route  SET id=?,ccr_name=?,fortification_intensity=?,line_length=?,cost_line=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where ccr_id=?",
                    entity.getId(), entity.getCcrName(), entity.getFortificationIntensity(), entity.getLineLength(), entity.getCostLine(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getCcrId()
            );
        } else if (k == 9) {
            SmxDevicesEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxDevicesEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_devices  SET in_object_name=?,location=?,object_lon=?,object_lat=?,device_type=?,device_name=?,model=?,in_floor=?,fixed_form=?,built_era=?,fortification=?,bolt_diameter=?,purchase_cost=?,manufacturers=?,size=?,weight=?,above_ground_height=?,natural_period=?,site=?,region=?,total_height=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where id=?",
                    entity.getInObjectName(), entity.getLocation(), entity.getObjectLon(), entity.getObjectLat(), entity.getDeviceType(), entity.getDeviceName(), entity.getModel(), entity.getInFloor(), entity.getFixedForm(), entity.getBuiltEra(), entity.getFortification(), entity.getBoltDiameter(), entity.getPurchaseCost(), entity.getManufacturers(), entity.getSize(), entity.getWeight(), entity.getAboveGroundHeight(), entity.getNaturalPeriod(), entity.getSite(), entity.getRegion(), entity.getTotalHeight(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getId()
            );
        } else if (k == 10) {
            SmxTvTowerEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxTvTowerEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_tv_tower  SET object_name=?,location=?,object_lon=?,object_lat=?,ctt_type=?,area=?,year=?,height=?,tower_elevation=?,bulding_site=?,design_intensity=?,field_type=?,status=?,reconstruction_cost=?,antenna_elevation=?,period=?,colmn_type=?,base_type=?,base_story_num=?,base_height=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                            + " where ctt_id=?",
                    entity.getObjectName(), entity.getLocation(), entity.getObjectLon(), entity.getObjectLat(), entity.getCttType(), entity.getArea(), entity.getYear(), entity.getHeight(), entity.getTowerElevation(), entity.getBuldingSite(), entity.getDesignIntensity(), entity.getFieldType(), entity.getStatus(), entity.getReconstructionCost(), entity.getAntennaElevation(), entity.getPeriod(), entity.getColmnType(), entity.getBaseType(), entity.getBaseStoryNum(), entity.getBaseHeight(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                    entity.getCttId()
            );
        } else if (k == 11) {
            SmxWaterRoomEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxWaterRoomEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_water_room  SET waterworks_name=?,building_name=?,brick_masonry_label=?,liquefaction6=?,liquefaction7=?,liquefaction8=?,liquefaction9=?,seismic_subsidence6=?,seismic_subsidence7=?,seismic_subsidence8=?,seismic_subsidence9=?,update_user=?,update_time=?"
                            + " where id=?",
                    entity.getWaterworksName(), entity.getBuildingName(), entity.getBrickMasonryLabel(), entity.getLiquefaction6(), entity.getLiquefaction7(), entity.getLiquefaction8(), entity.getLiquefaction9(), entity.getSeismicSubsidence6(), entity.getSeismicSubsidence7(), entity.getSeismicSubsidence8(), entity.getSeismicSubsidence9(), entity.getUpdateUser(), entity.getUpdateTime(),
                    entity.getId()
            );
        } else if (k == 12) {
            SmxPowerhouseEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxPowerhouseEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_powerhouse  SET name=?,position=?,installed_capacity=?,power_generation_type=?,construction=?,substation_construction=?,ep_construction=?,area=?,unit_price=?,update_user=?,update_time=?"
                            + " where id=?",
                    entity.getName(), entity.getPosition(), entity.getInstalledCapacity(), entity.getPowerGenerationType(), entity.getConstruction(), entity.getSubstationConstruction(), entity.getEpConstruction(), entity.getArea(), entity.getUnitPrice(), entity.getUpdateUser(), entity.getUpdateTime(),
                    entity.getId()
            );
        } else if (k == 13) {
            SmxBaseStationEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxBaseStationEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_base_station  SET name=?"
                            + " where id=?",
                    entity.getName(),
                    entity.getId()
            );
        } else if (k == 14) {
            SmxGasStoreEntity entity = JSONObject.parseObject(JSONObject.toJSONBytes(v), SmxGasStoreEntity.class);
            entity.setUpdateUser(userId);
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_smx_gas_store  SET name=?"
                            + " where id=?",
                    entity.getName(),
                    entity.getId()
            );
        } else if(k == 16){
            CztMajorProjectsEntity entity = JSONObject.parseObject(JSONObject.toJSONString(v), CztMajorProjectsEntity.class);
            entity.setUpdateUser(PlatformSessionUtils.getUserId());
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_major_projects  SET seism_name=?,seism_date=?,seism_time=?,magnitude=?,project_type=?,year=?,destructive6_state=?,destructive7_state=?,destructive8_state=?,destructive9_state=?,destructive10_state=?,destructive11_state=?,destructive12_state=?,update_user=?,update_time=?"
                            +" where id=?",
                    entity.getSeismName(),entity.getSeismDate(),entity.getSeismTime(),entity.getMagnitude(),entity.getProjectType(),entity.getYear(),entity.getDestructive6State(),entity.getDestructive7State(),entity.getDestructive8State(),entity.getDestructive9State(),entity.getDestructive10State(),entity.getDestructive11State(),entity.getDestructive12State(),entity.getUpdateUser(),entity.getUpdateTime(),
                    entity.getId()
            );
        }else if(k == 17){
            RdInformationEntity entity = JSONObject.parseObject(JSONObject.toJSONString(v), RdInformationEntity.class);
            entity.setUpdateUser(PlatformSessionUtils.getUserId());
            entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
            jdbcTemplate.update("UPDATE  czt_reservior  SET cr_name=?,location=?,longitude=?,latitude=?,capacity=?,year=?,dam_length=?,dam_height=?,top_width=?,structure_type=?,type=?,intensity=?,site=?,space=?,filling=?,dam_foundation=?,maintenance_status=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?,attach_id=?,province=?,city=?,county=?,upload_time=?"
                            +" where cr_id=?",
                    entity.getCrName(),entity.getLocation(),entity.getLongitude(),entity.getLatitude(),entity.getCapacity(),entity.getYear(),entity.getDamLength(),entity.getDamHeight(),entity.getTopWidth(),entity.getStructureType(),entity.getType(),entity.getIntensity(),entity.getSite(),entity.getSpace(),entity.getFilling(),entity.getDamFoundation(),entity.getMaintenanceStatus(),entity.getUpdateUser(),entity.getUpdateTime(),entity.getExtends1(),entity.getExtends2(),entity.getExtends3(),entity.getExtends4(),entity.getExtends5(),entity.getExtends6(),entity.getExtends7(),entity.getExtends8(),entity.getExtends9(),entity.getExtends10(),entity.getAttachId(),entity.getProvince(),entity.getCity(),entity.getCounty(),entity.getUploadTime(),
                    entity.getCrId()
            );
        }
    }

    @Override
    public List<EvaluationResults> getAnalysisByVersionId(Integer type, String id) {
        /*
        1地下管网，2水厂水池，3燃气储气罐  4 桥梁 5道路 6变电站  8电缆线路 9通信室内设备 11 水厂泵房 12 重要发电厂房 13 通信基站  14 燃气门站  15 供气
         */
        StringBuilder sql = new StringBuilder();
        List<EvaluationResults> list = null;
        if (type == 1 || type == 15) {
            sql.append("select id,up_id as extends1,name as extends2,type as extends3,start_id as extends4,end_id as extends5,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,ST_AsText(geom) geom,longitude,latitude ,1 as type from czt_smx_up_network where del_flag = '0' and version_id = '" + id + "'");
        } else if (type == 2) {
            sql.append("select id,water_supply_id as extends1,style as extends2,material as extends3,thickness as extends4 ,shape as extends5,radius as extends6,slength as extends7,disaster_rate_state as disaster_rate6_state, disaster_rate_state as disaster_rate7_state, disaster_rate_state as disaster_rate8_state, disaster_rate_state as disaster_rate9_state, disaster_rate_state as disaster_rate10_state,longitude,latitude,ST_AsText(geom) geom,2 as type from czt_smx_water_supply where del_flag = '0' and version_id = '" + id + "'");
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(EvaluationResults.class));
            if (PlatformObjectUtils.isNotEmpty(list)) {
                list.forEach(it -> {
                    it.setExtends2(getValueByKey("smxgsjgxs", it.getExtends2()));
                    it.setExtends3(getValueByKey("smxgsjgcl", it.getExtends3()));
                    it.setExtends5(getValueByKey("smxgsscxz", it.getExtends5()));
                });
            }
            return list;
        } else if (type == 3) {
            sql.append("select id,air_receiver_id as extends1,name as extends2,longitude,latitude,style as extends3,capacity as extends4 ,pressure as extends5,ST_AsText(geom) geom,3 as type from czt_smx_air_receiver where del_flag = '0' and version_id = '" + id + "'");
        } else if (type == 4) {
            sql.append("select id,bridge_id as extends1,name as extends2,longitude,latitude,fortification as extends3,intensity as extends4 ,year as extends5,structure as extends6, damage as disaster_rate6_state, damage as disaster_rate7_state, damage as disaster_rate8_state, damage as disaster_rate9_state, damage as disaster_rate10_state,ST_AsText(geom) geom,4 as type from czt_smx_bridge_point where del_flag = '0' and version_id = '" + id + "' ");
            sql.append(" union all select id,bridge_id as extends1,name as extends2,longitude,latitude,fortification as extends3,intensity as extends4 ,year as extends5,structure as extends6, damage as disaster_rate6_state, damage as disaster_rate7_state, damage as disaster_rate8_state, damage as disaster_rate9_state, damage as disaster_rate10_state,ST_AsText(geom) geom,4 as type from czt_smx_bridge_line where del_flag = '0' and version_id = '" + id + "' ");
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(EvaluationResults.class));
            if (PlatformObjectUtils.isNotEmpty(list)) {
                list.forEach(it -> {
                    it.setExtends3(getValueByKey("smxsfqk", it.getExtends3()));
                    it.setExtends4(getValueByKey("smxsfld", it.getExtends4()));
                    it.setExtends6(getValueByKey("smxqljglx", it.getExtends6()));
                });
            }
            return list;
        } else if (type == 5) {
            sql.append("select id,road_id as extends1,name as extends2,grade as extends3,intensity as extends4 ,roadbed_soil as extends5,site_soil as extends6, fortification as extends7,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,ST_AsText(geom) geom,5 as type,start_longitude,start_latitude,end_longitude,end_latitude from czt_smx_road where del_flag = '0' and version_id = '" + id + "'");
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(EvaluationResults.class));
            if (PlatformObjectUtils.isNotEmpty(list)) {
                for (EvaluationResults entity : list) {
                    List<String> centerPoint = getCenterPoint(entity);
                    entity.setLongitude(centerPoint.get(0));
                    entity.setLatitude(centerPoint.get(1));
                    entity.setExtends3(getValueByKey("smxdldj", entity.getExtends3()));
                    entity.setExtends4(getValueByKey("smxsfld", entity.getExtends4()));
                    entity.setExtends5(getValueByKey("smxdlljt", entity.getExtends5()));
                    entity.setExtends6(getValueByKey("smxcdlb", entity.getExtends6()));
                    entity.setExtends7(getValueByKey("smxdlsfqk", entity.getExtends7()));
                }
            }
            return list;
        } else if (type == 6) {
            sql.append("select id,ts_id as extends1,name as extends2,position as extends3,longitude,latitude,type_of_ubstation as extends4 ,voltage_grade as extends5,ST_AsText(geom) geom,6 as type from czt_smx_transformer_substation where del_flag = '0' and version_id = '" + id + "'");
        } else if (type == 8) {
            sql.append("select ccr_id as id,id as extends1,ccr_name as extends2,longitude,latitude,fortification_intensity as extends3 ,line_length as extends4,cost_line as extends5,ST_AsText(geom) geom,8 as type from czt_smx_cable_route where del_flag = '0' and version_id = '" + id + "'");
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(EvaluationResults.class));
            if (PlatformObjectUtils.isNotEmpty(list)) {
                list.forEach(it -> {
                    it.setExtends3(getValueByKey("smxsfld", it.getExtends3()));
                });
            }
            return list;
        } else if (type == 9) {
            sql.append("select id,in_object_name as extends1,location as extends2,built_era as extends3,fortification as extends4,device_type as extends5,site as extends6,device_name as extends7,model as extends8,ST_AsText(geom) geom,object_lon as longitude,object_lat as latitude,9 as type from czt_smx_devices where del_flag = '0' and version_id = '" + id + "'");
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(EvaluationResults.class));
            if (PlatformObjectUtils.isNotEmpty(list)) {
                list.forEach(it -> {
                    it.setExtends4(getValueByKey("smxsfqk", it.getExtends4()));
                    it.setExtends5(getValueByKey("smxtxsblb", it.getExtends5()));
                    it.setExtends6(getValueByKey("smxcdlb", it.getExtends6()));
                });
            }
            return list;
        } else if (type == 11) {
            sql.append("select id,longitude,latitude,num_type as extends1,building_name as extends2,structure_type as extends3,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,longitude,latitude,ST_AsText ( geom ) geom,11 as type from czt_smx_water_room where del_flag = '0' and version_id = '" + id + "'");
        } else if (type == 12) {
            sql.append("select id,name as extends1,structure_type as extends2,position as extends3,longitude,latitude,power_generation_type as extends4,construction as extends5,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,longitude,latitude,ST_AsText ( geom ) geom,12 as type from czt_smx_powerhouse where del_flag = '0' and version_id = '" + id + "'");
        } else if (type == 13) {
            sql.append("select id,num_type as extends1,name as extends2,structure_type as extends3,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,longitude,latitude,ST_AsText ( geom ) geom,13 as type from czt_smx_base_station where del_flag = '0' and version_id = '" + id + "'");
        } else if (type == 14) {
            sql.append("select id,num_type as extends1,name as extends2,structure_type as extends3,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,longitude,latitude,ST_AsText ( geom ) geom,14 as type from czt_smx_gas_store where del_flag = '0' and version_id = '" + id + "'");
        }
        list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(EvaluationResults.class));
        return list;
    }

    private String getValueByKey(String code, String key) {
        if (!PlatformObjectUtils.isEmpty(key)) {
            return dictService.getValueByDictCodeAndKey(code, key);
        }
        return null;
    }

    private List<String> getCenterPoint(EvaluationResults road) {
        String geom = road.getStartLongitude() + " " + road.getEndLongitude() + " ," + road.getStartLatitude() + " " + road.getEndLatitude();
        List<String> centerLonLat = new ArrayList<>();
        if (PlatformObjectUtils.isNotEmpty(geom)) {
            String sql = "select ST_ASTEXT(st_centroid(st_geomfromtext('LINESTRING(" + geom + ")',4490))) as geom";
            String centerPoint = null;
            try {
                centerPoint = jdbcTemplate.queryForObject(sql, String.class);
            } catch (DataAccessException e) {
                log.error(e.getMessage(), e);
            }
            if (PlatformObjectUtils.isNotEmpty(centerPoint) && centerPoint.indexOf("POINT(") != -1) {
                String lonlatStr = centerPoint.replace("POINT(", "").replace(")", "");
                String[] lonlat = lonlatStr.split(" ");
                if (lonlat.length == 2) {
                    centerLonLat.add(lonlat[0]);//经度
                    centerLonLat.add(lonlat[1]);//纬度
                }
            }
        }
        return centerLonLat;
    }

    @Override
    public boolean saveOverheadLine(SmxOverheadLineEntity overheadLineEntity) {
        String sql = "insert into czt_smx_overhead_line values(:colId,:id,:colName,:fortificationIntensity,:voltageGrade35,:lineLength35,:loopLength35,:landform35,:unitCostLine35,:type35,:number35,:unitCostTower35,:voltageGrade66,:lineLength66,:loopLength66,:landform66,:unitCostLine66,:type66,:number66,:unitCostTower66,:voltageGrade110,:lineLength110,:loopLength110,:landform110,:unitCostLine110,:type110,:number110,:unitCostTower110,:voltageGrade220,:lineLength220,:loopLength220,:landform220,:unitCostLine220,:type220,:number220,:unitCostTower220,:voltageGrade330,:lineLength330,:loopLength330,:landform330,:unitCostLine330,:type330,:number330,:unitCostTower330,:voltageGrade500,:lineLength500,:loopLength500,:landform500,:unitCostLine500,:type500,:number500,:unitCostTower500,:createUser,:createTime,:updateUser,:updateTime,:delFlag,ST_GeometryFromText(:geom,4490),:versionId,:tableId,:serialNumber,:extends1,:extends2,:extends3,:extends4,:extends5,:extends6,:extends7,:extends8,:extends9,:extends10,:site)";
        SqlParameterSource source = new BeanPropertySqlParameterSource(overheadLineEntity);
        return namedParameterJdbcTemplate.update(sql, source) > 0;
    }

    @Override
    public boolean saveCableRoute(SmxCableRouteEntity cableRouteEntity) {
        String sql = "insert into czt_smx_cable_route values(:ccrId,:id,:ccrName,:fortificationIntensity,:lineLength,:costLine,:createUser,:createTime,:updateUser,:updateTime,:delFlag,ST_GeometryFromText(:geom,4490),:versionId,:tableId,:serialNumber,:extends1,:extends2,:extends3,:extends4,:extends5,:extends6,:extends7,:extends8,:extends9,:extends10,:site,:level,:longitude,:latitude)";
        SqlParameterSource source = new BeanPropertySqlParameterSource(cableRouteEntity);
        return namedParameterJdbcTemplate.update(sql, source) > 0;
    }

    @Override
    public boolean saveTvTower(SmxTvTowerEntity tvTowerEntity) {
        String sql = "insert into czt_smx_tv_tower values(:cttId,:objectName,:location,:objectLon,:objectLat,:cttType,:area,:year,:height,:towerElevation,:buldingSite,:designIntensity,:fieldType,:status,:reconstructionCost,:antennaElevation,:period,:colmnType,:baseType,:baseStoryNum,:baseHeight,:createUser,:createTime,:updateUser,:updateTime,:delFlag,ST_GeometryFromText(:geom,4490),:versionId,:tableId,:serialNumber,:extends1,:extends2,:extends3,:extends4,:extends5,:extends6,:extends7,:extends8,:extends9,:extends10)";
        SqlParameterSource source = new BeanPropertySqlParameterSource(tvTowerEntity);
        return namedParameterJdbcTemplate.update(sql, source) > 0;
    }

    @Override
    public void deleteByTypeAndVersionId(String versionId) {
        String sql = "update czt_smx_version set del_flag = '1' where id = '" + versionId + "'";
        jdbcTemplate.update(sql);
    }

    @Override
    public void deleteValueByTypeAndVersionId(String versionId, Integer type, Integer bridgeType) {
        StringBuilder sql = new StringBuilder("update ");
        if (type == 1) {
            sql.append(" czt_smx_up_network");
        } else if (type == 2) {
            sql.append(" czt_smx_water_supply");
        } else if (type == 3) {
            sql.append(" czt_smx_air_receiver");
        } else if (type == 4) {
            if (bridgeType == 0) {
                sql.append(" czt_smx_bridge_point");
            } else {
                sql.append(" czt_smx_bridge_line");
            }
        } else if (type == 5) {
            sql.append(" czt_smx_road");
        } else if (type == 6) {
            sql.append(" czt_smx_transformer_substation");
        } else if (type == 7) {
            sql.append(" czt_smx_overhead_line");
        } else if (type == 8) {
            sql.append(" czt_smx_cable_route");
        } else if (type == 9) {
            sql.append(" czt_smx_devices");
        } else if (type == 10) {
            sql.append(" czt_smx_tv_tower");
        } else if (type == 11) {
            sql.append(" czt_smx_water_room");
        } else if (type == 12) {
            sql.append(" czt_smx_powerhouse");
        } else if (type == 13) {
            sql.append(" czt_smx_base_station");
        } else if (type == 14) {
            sql.append(" czt_smx_gas_store");
        } else if (type == 16) {
            sql.append(" czt_major_projects");
        } else if (type == 17) {
            sql.append(" czt_reservior");
        }
        sql.append(" set del_flag = '1' where version_id = '" + versionId + "'");
        jdbcTemplate.update(sql.toString());
    }

    @Override
    public void updateMainCalculationStatusByTableId(String tableId) {
        String userID = PlatformSessionContext.getUserID();
        Timestamp currentTimestamp = PlatformDateUtils.getCurrentTimestamp();
        String sql = "update czt_smx_main_table set calculation_status = '2',update_user='" + userID + "',update_time ='" + currentTimestamp + "' where id = '" + tableId + "'";
        jdbcTemplate.update(sql);
    }

    @Override
    public void deleteMainByVersionId(String versionId) {
        String sql = "update czt_smx_main_table set del_flag = '1' where version_id = '" + versionId + "'";
        jdbcTemplate.update(sql);
    }

    @Override
    public Map<String, Object> getBasicByIdAndType(Integer type, String id) {
        Map map = new HashMap<>();
        try {
            if (type == 1 || type == 15) {
                String sql = "select * from czt_smx_up_network where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 2) {
                String sql = "select * from czt_smx_water_supply where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 3) {
                String sql = "select * from czt_smx_air_receiver where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 4) {
                String sql = "select * from czt_smx_bridge_point where id = '" + id + "' union all select * from czt_smx_bridge_line where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 5) {
                String sql = "select * from czt_smx_road where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 6) {
                String sql = "select * from czt_smx_transformer_substation where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 8) {
                String sql = "select * from czt_smx_cable_route where ccr_id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 9) {
                String sql = "select * from czt_smx_devices where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 11) {
                String sql = "select * from czt_smx_water_room where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 12) {
                String sql = "select * from czt_smx_powerhouse where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 13) {
                String sql = "select * from czt_smx_base_station where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            } else if (type == 14) {
                String sql = "select * from czt_smx_gas_store where id = '" + id + "'";
                map = jdbcTemplate.queryForMap(sql);
            }
        } catch (DataAccessException e) {
            log.error("error:{}", e.getMessage(), e);
            map = new HashMap<>();
        }
        return map;
    }

    @Override
    public int getCalculationResultsByVersionId(String id) {
        String sql = "select count(1) from czt_smx_main_table where version_id = '" + id + "' and calculation_status != 1";
        return jdbcTemplate.queryForObject(sql, Integer.class);
    }

    @Override
    public Integer getAllCalculationResultsByVersionId(String id) {
        String sql = "select count(1) from czt_smx_main_table where version_id = '" + id + "' and calculation_status = 1";
        return jdbcTemplate.queryForObject(sql, Integer.class);
    }

    @Override
    public LifelineIdVo getTableIdByIdAndType(String dataId, Integer type) {
        String fieldName = "id";
        StringBuilder sql = new StringBuilder("select * from");
        if (type == 1) {
            sql.append(" czt_smx_up_network");
        } else if (type == 2) {
            sql.append(" czt_smx_water_supply");
        } else if (type == 3) {
            sql.append(" czt_smx_air_receiver");
        } else if (type == 4) {
            sql.append(" czt_smx_bridge_point");
        } else if (type == 5) {
            sql.append(" czt_smx_road");
        } else if (type == 6) {
            sql.append(" czt_smx_transformer_substation");
        } else if (type == 7) {
            fieldName = "col_id";
            sql.append(" czt_smx_overhead_line");
        } else if (type == 8) {
            fieldName = "ccr_id";
            sql.append(" czt_smx_cable_route");
        } else if (type == 9) {
            sql.append(" czt_smx_devices");
        } else if (type == 10) {
            fieldName = "ctt_id";
            sql.append(" czt_smx_tv_tower");
        } else if (type == 11) {
            sql.append(" czt_smx_water_room");
        } else if (type == 12) {
            sql.append(" czt_smx_powerhouse");
        } else if (type == 13) {
            sql.append(" czt_smx_base_station");
        } else if (type == 14) {
            sql.append(" czt_smx_gas_store");
        } else if (type == 16) {
            sql.append(" czt_major_projects");
        } else if (type == 17) {
            fieldName = "cr_id";
            sql.append(" czt_reservior");
        }
        sql.append(" where " + fieldName + " = '" + dataId + "'");

        if (type == 4) {
            sql.append(" union all select table_id,version_id from czt_smx_bridge_line  where id = '" + dataId + "'");
        }
        return jdbcTemplate.queryForObject(sql.toString(), new BeanPropertyRowMapper<>(LifelineIdVo.class));
    }

    @Override
    public void deleteMainByTableId(String tableId) {
        String sql = "update czt_smx_main_table set del_flag = '1' where id = '" + tableId + "'";
        jdbcTemplate.update(sql);
    }

    @Override
    public void deleteByVersionId(String versionId) {
        String sql = "update czt_crs_calentirety_result set del_flag = '1' where version_id = '" + versionId + "'";
        jdbcTemplate.update(sql);
    }

    @Override
    public void deleteZhByVersionId(String versionId) {
        String sql = "update czt_brick_concrete_building_info set del_flag = '1' where version_id = '" + versionId + "'";
        jdbcTemplate.update(sql);
    }

    @Override
    public void deleteGhByTableId(String id) {
        String sql = "update czt_crs_calentirety_result set del_flag = '1' where table_id = '" + id + "'";
        jdbcTemplate.update(sql);
    }

    @Override
    public void deleteZhByTableId(String id) {
        String sql = "update czt_brick_concrete_building_info set del_flag = '1' where table_id = '" + id + "'";
        jdbcTemplate.update(sql);
    }

    @Override
    public int getDataCountByVersionId(Integer type, String versionId) {
        StringBuilder sql = new StringBuilder("select count(1) from");
        if (type == 1) {
            sql.append(" czt_smx_up_network");
        } else if (type == 2) {
            sql.append(" czt_smx_water_supply");
        } else if (type == 3) {
            sql.append(" czt_smx_air_receiver");
        } else if (type == 4) {
            sql.append(" czt_smx_bridge_point");
        } else if (type == 5) {
            sql.append(" czt_smx_road");
        } else if (type == 6) {
            sql.append(" czt_smx_transformer_substation");
        } else if (type == 7) {
            sql.append(" czt_smx_overhead_line");
        } else if (type == 8) {
            sql.append(" czt_smx_cable_route");
        } else if (type == 9) {
            sql.append(" czt_smx_devices");
        } else if (type == 10) {
            sql.append(" czt_smx_tv_tower");
        } else if (type == 11) {
            sql.append(" czt_smx_water_room");
        } else if (type == 12) {
            sql.append(" czt_smx_powerhouse");
        } else if (type == 13) {
            sql.append(" czt_smx_base_station");
        } else if (type == 14) {
            sql.append(" czt_smx_gas_store");
        } else if( type == 16){
            sql.append(" czt_major_projects");
        }else if( type == 17){
            sql.append(" czt_reservior");
        }
        sql.append(" where version_id = '" + versionId + "' and del_flag = '0'");
        return jdbcTemplate.queryForObject(sql.toString(), Integer.class);
    }

    @Override
    public void updateBridgeLineById(Object v, String userId) {
        SmxBridgeEntity entity = JSONObject.parseObject(JSONObject.toJSONString(v), SmxBridgeEntity.class);
        entity.setUpdateUser(userId);
        entity.setUpdateTime(PlatformDateUtils.getCurrentTimestamp());
        jdbcTemplate.update("UPDATE  czt_smx_bridge_line SET bridge_id=?,longitude=?,latitude=?,across_object=?,intensity=?,year=?,fortification=?,structure=?,max_span=?,length=?,site_soil=?,grade=?,foundation_fail=?,super_structure=?,bearing=?,pier_height=?,pier_material=?,basement=?,number=?,capacity=?,abutment_mat=?,abutment_type=?,expansion_joint=?,width=?,note=?,name=?,update_user=?,update_time=?,extends1=?,extends2=?,extends3=?,extends4=?,extends5=?,extends6=?,extends7=?,extends8=?,extends9=?,extends10=?"
                        + " where id=?",
                entity.getBridgeId(), entity.getLongitude(), entity.getLatitude(), entity.getAcrossObject(), entity.getIntensity(), entity.getYear(), entity.getFortification(), entity.getStructure(), entity.getMaxSpan(), entity.getLength(), entity.getSiteSoil(), entity.getGrade(), entity.getFoundationFail(), entity.getSuperStructure(), entity.getBearing(), entity.getPierHeight(), entity.getPierMaterial(), entity.getBasement(), entity.getNumber(), entity.getCapacity(), entity.getAbutmentMat(), entity.getAbutmentType(), entity.getExpansionJoint(), entity.getWidth(), entity.getNote(), entity.getName(), entity.getUpdateUser(), entity.getUpdateTime(), entity.getExtends1(), entity.getExtends2(), entity.getExtends3(), entity.getExtends4(), entity.getExtends5(), entity.getExtends6(), entity.getExtends7(), entity.getExtends8(), entity.getExtends9(), entity.getExtends10(),
                entity.getId()
        );
    }

    @Override
    public void deleteLineById(String id) {
        String sql = "update czt_smx_bridge_line set del_flag = '1' where id = " + id;
        jdbcTemplate.update(sql);
    }

    @Override
    public int getBridgeLineCountByVersionId(String versionId) {
        String sql = "select count(*) from czt_smx_bridge_line where version_id = '" + versionId + "' and del_flag = '0'";
        return jdbcTemplate.queryForObject(sql, Integer.class);
    }

    @Override
    public List<String> getVectorDataIdsByVersionId(String versionId, Integer type) {
        String tableName = "czt_smx_transformer_substation";
        String fileName = "ts_id";
        if (type == 16) {
            tableName = "czt_smx_base_station";
            fileName = "code";
        }
        String sql = "select " + fileName + " as id from " + tableName + " where del_flag = '0' and version_id = '" + versionId + "'";
        List<String> results = jdbcTemplate.query(sql, new String[0], new RowMapper<String>() {
            @Override
            public String mapRow(ResultSet rs, int rowNum) throws SQLException {
                return rs.getString("id");
            }
        });
        return results;
    }

    @Override
    public ArrayList<Object> getByTypeAndGeomAndVersionId(String geom, Integer type, String versionId, Integer viewingMethods) {
        ArrayList<Object> resultList = new ArrayList<>();
        StringBuilder sql = new StringBuilder();
        try {
            if (type == 1) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_up_network");
            } else if (type == 2) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_water_supply");
            } else if (type == 3) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_air_receiver");
            } else if (type == 4) {
                sql.append("select *,ST_AsText(geom) geom from czt_smx_bridge_point where version_id = '" + versionId + "' and del_flag = '0' and st_within(st_centroid(st_geomfromtext('" + geom + "',4490)),geom) union all select *,ST_AsText ( geom ) geom from czt_smx_bridge_line where version_id = '" + versionId + "' and del_flag = '0' and st_within(st_centroid(st_geomfromtext('" + geom + "',4490)),geom)");
            } else if (type == 5) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_road ");
            } else if (type == 6) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_transformer_substation");
            } else if (type == 7) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_overhead_line");
            } else if (type == 8) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_cable_route");
            } else if (type == 9) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_devices");
            } else if (type == 10) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_tv_tower");
            } else if (type == 11) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_water_room");
            } else if (type == 12) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_powerhouse");
            } else if (type == 13) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_base_station");
            } else if (type == 14) {
                sql.append("select *,ST_AsText(a.geom) geom from czt_smx_gas_store");
            } else if(type == 16){
                sql.append("select *,ST_AsText(a.geom) geom from czt_major_projects");
            }else if(type == 17){
                sql.append("select *,ST_AsText(a.geom) geom from czt_reservior");
            }

            if (type != 4) {
                sql.append(" a, (select ST_GeometryFromText('" + geom + "',4490) as geom) t");
                sql.append(" where del_flag = '0' and version_id = '" + versionId + "' and ST_Intersects(a.geom,t.geom) and ST_Touches(a.geom,t.geom)!='t' ");
            }

            if (type == 1) {
                List<SmxUpNetworkEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxUpNetworkEntity.class));
                resultList.addAll(list);
            } else if (type == 2) {
                List<SmxWaterSupplyEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxWaterSupplyEntity.class));
                resultList.addAll(list);
            } else if (type == 3) {
                List<SmxAirReceiverEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxAirReceiverEntity.class));
                resultList.addAll(list);
            } else if (type == 4) {
                List<SmxBridgeEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxBridgeEntity.class));
                resultList.addAll(list);
            } else if (type == 5) {
                List<SmxRoadEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxRoadEntity.class));
                resultList.addAll(list);
            } else if (type == 6) {
                List<SmxTransformerSubstationEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxTransformerSubstationEntity.class));
                resultList.addAll(list);
            } else if (type == 7) {
                List<SmxOverheadLineEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxOverheadLineEntity.class));
                resultList.addAll(list);
            } else if (type == 8) {
                List<SmxCableRouteEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxCableRouteEntity.class));
                resultList.addAll(list);
            } else if (type == 9) {
                List<SmxDevicesEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxDevicesEntity.class));
                resultList.addAll(list);
            } else if (type == 10) {
                List<SmxTvTowerEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxTvTowerEntity.class));
                resultList.addAll(list);
            } else if (type == 11) {
                List<SmxWaterRoomEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxWaterRoomEntity.class));
                resultList.addAll(list);
            } else if (type == 12) {
                List<SmxPowerhouseEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxPowerhouseEntity.class));
                resultList.addAll(list);
            } else if (type == 13) {
                List<SmxBaseStationEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxBaseStationEntity.class));
                resultList.addAll(list);
            } else if (type == 14) {
                List<SmxGasStoreEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(SmxGasStoreEntity.class));
                resultList.addAll(list);
            }else if (type == 16) {
                List<CztMajorProjectsEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(CztMajorProjectsEntity.class));
                resultList.addAll(list);
            } else if (type == 17) {
                List<RdInformationEntity> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(RdInformationEntity.class));
                resultList.addAll(list);
            }
            return resultList;
        } catch (DataAccessException e) {
            log.error("error:{}", e.getMessage(), e);
            return null;
        }
    }
}
